<?php
/**
 * Date: 2024.8
 * Author: kahn
 * 小程序内支付
 */
use config\Response;
use service\vip\payment\WxpayService;
class MicroController extends Controller
{
    /**
     * 微信小程序支付前通过code获取openId
     * @return void
     */
    public function openIdAction(): void
    {
        $code = $this->_getParam('code','string',true);

        $openId = WxpayService::getMicroOpenId($code);
        if(!$openId){
            $this->_response(Response::MICRO_OPENID_FAIL);
        }

        $this->_response(Response::SUCCESS, ['openId'=>$openId]);
    }

}

